import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [
    react(),
  ],

  // 依赖优化配置
  optimizeDeps: {
    include: [
      'immer',
      'zustand',
      'zustand/middleware',
      'zustand/middleware/immer'
    ]
  },

  // 路径别名配置
  resolve: {
    alias: {
      '@': '/src',
      '@/components': '/src/components',
      '@/pages': '/src/pages',
      '@/hooks': '/src/hooks',
      '@/services': '/src/services',
      '@/stores': '/src/stores',
      '@/utils': '/src/utils',
      '@/types': '/src/types',
      '@/styles': '/src/styles',
      '@/assets': '/src/assets',
      '@/workers': '/src/workers',
      '@/test': '/src/test'
    }
  },

  // 开发服务器配置
  server: {
    port: 3000,
    open: true,
    host: true
  },

  // 构建配置
  build: {
    outDir: 'dist',
    target: 'es2020',
    rollupOptions: {
      output: {
        manualChunks: {
          'zustand-vendor': ['zustand', 'immer']
        }
      }
    }
  },

  // CSS 配置
  css: {
    modules: {
      localsConvention: 'camelCase'
    }
  }
});
